#include <iostream>
using namespace std;

#define int long long

const int N = 300 , M = 1e6 + 10;
int n , m;
int cnt[N] , v[N];
int f[M];
int sum;
signed main()
{
    cin >> n >> m;
    for(int i = 1;i <= n;i ++) cin >> cnt[i];
    for(int i = 1;i <= n;i ++)
    {
        cin >> v[i];
        sum += v[i] * cnt[i];
    }
    f[0] = 1;
    for(int i = 1;i <= n;i ++)
        for(int j = sum;j >= 0;j --)
            for(int k = 0;k <= cnt[i] && k * v[i] <= j;k ++)
            {
                f[j] = max(f[j] , f[j - k * v[i]] * k);
            }

    for(int i = 1;i <= sum;i ++)
    {
        if(f[i] >= m)
        {
            cout << i << endl;
            break;
        }
    }
    
    return 0;
}